package cn.swing.learning;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

/**
 * Desc : TODO
 * ClassName : cn.swing.learning.IntegralDialog
 *
 * @author : 林鹏群
 * @date : 2022/12/24 8:56
 */
public class IntegralDialog extends JDialog {

    private RankingListTabel rankingListTabel;

    public IntegralDialog() {
        this.setTitle("游戏成功");
        //设置初始化位置
        this.setLocation(500,500);
        //设置关闭事件 EXIT_ON_CLOSE
//        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //设置图标
        this.setIconImage(new ImageIcon("./picture/icon.gif").getImage());
        //设置大小
        this.setSize(300,400);
        //设置布局
        this.setLayout(null);
        this.setVisible(true);

        JLabel label = new JLabel("请输入你的姓名");
        label.setBounds(50,10,200,50);
        JTextField textField = new JTextField("");

        textField.setBounds(50,70,200,50);

        JButton button = new JButton("提交");
        button.setBounds(100,150,80,50);

        JButton delete = new JButton("删除");
        delete.setBounds(200,150,80,50);

        JButton query = new JButton("查询");
        query.setBounds( 0,150,80,50);

        this.add(label);
        this.add(textField);
        this.add(button);
        this.add(delete);
        this.add(query);

        rankingListTabel = new RankingListTabel(Tools.cellData, Tools.columnNames);
        JScrollPane jScrollPane = new JScrollPane(rankingListTabel);
        jScrollPane.setBounds(10,220,260,120);

        button.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                rankingListTabel.addData(Tools.level,textField.getText(),textField.getText());
            }
        });


        delete.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                rankingListTabel.delData();
            }
        });


        query.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                rankingListTabel.queryData();
            }
        });

        this.add(jScrollPane);
    }
}
